package Entity;

import java.util.*;
import Controller.*;
import java.io.Serializable;

/**
 * This is one of the reports.
 * this report is for complaints, and it will be produced to the company manager.
 * @author Shahar Shelli
 *
 */
public class ComplaintReport extends Report implements Serializable
{
	private static final long serialVersionUID = -8453550170756470197L;
	
	private Date start;
	private Complaint[] c;
	private int parkingLot;
	
	/**
	 * is the constructor. it will call the super constructor 
	 * and also set the number of complaints.
	 * this will be a report for a specific parking lot.
	 * @param s= the start date.
	 * @param e= the end date. e and s will determine the period of time.
	 * @param des= the description for the report.(optional that's why we need this constructor)
	 * @param p= the parking lot number.
	 */
	public ComplaintReport(Date s,Date e,String desc,int p)
	{
		super(e,desc);
		this.parkingLot=p;
		this.start=s;
		this.c=DBcontroller.getComplaints(s, e);
	}
	
	/**
	 * is the constructor. it will call the super constructor 
	 * and also set the number of complaints.
	 * this will be a report for a specific parking lot.
	 * @param s= the start date.
	 * @param e= the end date. e and s will determine the period of time.
	 * @param p= the parking lot number.
	 */
	public ComplaintReport(Date s,Date e,int p)
	{
		super(e,"");
		this.start=s;
		this.c=DBcontroller.getComplaints(s, e);
	}
	
	// the get functions.
	public int getNumOfComplaint()
	{
		return this.c.length;
	}
	
	public boolean Validate(Date s,Date e,String desc,int p)
	{
		if(s.after(e))
			return false;
		return true;
	}
	
	public int getParkingLot() {
		return parkingLot;
	}
	
	public Date getStart() {
		return start;
	}
	
	public Complaint[] getComplaints() {
		return c;
	}

	public static void save(ComplaintReport r) 
	{
		DBcontroller.saveComplaintReport(r);
	}

}
